package com.xiaohua.api.common.enums;

/**
 * 证件类型枚举类
 * 存放各种证件类型及其对应的代码和描述
 * 
 * @author 小花
 * @date 2025-03-30
 */
public enum CertTypeEnums {
    
    /**
     * 银行卡
     */
    BANK_CARD("bank_card", "银行卡", "data"),
    
    /**
     * 身份证
     */
    ID_CARD("id_card", "身份证", "data"),
    
    /**
     * 护照
     */
    PASSPORT("passport", "护照", "data"),
    
    /**
     * 驾驶证
     */
    DRIVER_LICENSE("driver_license", "驾驶证", "data"),
    
    /**
     * 行驶证
     */
    VEHICLE_LICENSE("vehicle_license", "行驶证", "data"),
    
    /**
     * 营业执照
     */
    BUSINESS_LICENSE("business_license", "营业执照", "data"),
    
    /**
     * 社保卡
     */
    SOCIAL_SECURITY_CARD("social_security_card", "社保卡", "data"),
    
    /**
     * 户口本
     */
    HOUSEHOLD_REGISTER("household_register", "户口本", "data"),
    
    /**
     * 结婚证
     */
    MARRIAGE_CERTIFICATE("marriage_certificate", "结婚证", "data"),
    
    /**
     * 房产证
     */
    PROPERTY_CERTIFICATE("property_certificate", "房产证", "data"),
    
    /**
     * 出生证明
     */
    BIRTH_CERTIFICATE("birth_certificate", "出生证明", "data"),
    
    /**
     * 学位证
     */
    DEGREE_CERTIFICATE("degree_certificate", "学位证", "data"),
    
    /**
     * 毕业证
     */
    GRADUATION_CERTIFICATE("graduation_certificate", "毕业证", "data"),
    
    /**
     * 未知类型
     */
    UNKNOWN("unknown", "未知证件类型", "data");
    
    /**
     * 证件类型代码
     */
    private final String code;
    
    /**
     * 证件类型中文描述
     */
    private final String description;
    
    /**
     * 证件信息键（用于JSON结果中的键名）
     */
    private final String infoKey;
    
    /**
     * 构造函数
     * 
     * @param code 证件类型代码
     * @param description 证件类型中文描述
     * @param infoKey 证件信息键
     */
    CertTypeEnums(String code, String description, String infoKey) {
        this.code = code;
        this.description = description;
        this.infoKey = infoKey;
    }
    
    /**
     * 获取证件类型代码
     * 
     * @return 证件类型代码
     */
    public String getCode() {
        return code;
    }
    
    /**
     * 获取证件类型中文描述
     * 
     * @return 证件类型中文描述
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * 获取证件信息键
     * 
     * @return 证件信息键
     */
    public String getInfoKey() {
        return infoKey;
    }
    
    /**
     * 根据证件类型代码获取枚举实例
     * 
     * @param code 证件类型代码
     * @return 证件类型枚举实例，如果找不到则返回UNKNOWN
     */
    public static CertTypeEnums getByCode(String code) {
        if (code == null || code.isEmpty()) {
            return UNKNOWN;
        }
        
        for (CertTypeEnums type : CertTypeEnums.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        
        return UNKNOWN;
    }
    
    /**
     * 根据证件类型代码获取中文描述
     * 
     * @param code 证件类型代码
     * @return 证件类型中文描述
     */
    public static String getDescriptionByCode(String code) {
        return getByCode(code).getDescription();
    }
    
    /**
     * 根据证件类型代码获取信息键
     * 
     * @param code 证件类型代码
     * @return 证件信息键
     */
    public static String getInfoKeyByCode(String code) {
        return getByCode(code).getInfoKey();
    }
} 